﻿@model Guline.SupportCMS.Models.Object.MenuItem

@{
    ViewBag.Title = "Create";
    Layout = "~/Views/Shared/v1_admin_layout.cshtml";
    List<Guline.SupportCMS.Models.Object.Category> categorys = (List<Guline.SupportCMS.Models.Object.Category>)ViewBag.Categorys;
}

<h1>
    <a href="@Url.Action("Index")"><i class="icon-arrow-left-3 fg-darker smaller"></i></a>
    Add new menu<small class="on-right"> thêm menu.</small>
</h1>
<div class="clearfix"></div>


@using (Html.BeginForm())
{
    @Html.AntiForgeryToken()
    @Html.ValidationSummary(true)

    <fieldset>
        <legend>MenuItem</legend>

        <div class="editor-label">
            @Html.LabelFor(model => model.Name)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Name)
            @Html.ValidationMessageFor(model => model.Name)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Menu_URL)
        </div>
        <div class="editor-field">
           
            <select id="slItemID" name="ItemID">
                <option value=""></option>
                @foreach (var n in categorys)
                {
                   
                    <option value="@Url.Action("Detail", "Subject", new { ID = n.ID, Name = Guline.SupportCMS.Models.Utils.Utils.UrlRewriteString(n.Name) })">@n.Name</option>
                    foreach (var k in n.Childrens)
                    {
                     
                    <option value="@Url.Action("Detail", "Subject", new { ID = k.ID, Name = Guline.SupportCMS.Models.Utils.Utils.UrlRewriteString(k.Name) })">-- @k.Name</option>
                       
                    }

                }
            </select>

            @Html.TextBoxFor(model => model.Menu_URL)
            @Html.ValidationMessageFor(model => model.Menu_URL)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Order)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Order)
            @Html.ValidationMessageFor(model => model.Order)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.ParentID, "Parent")
        </div>
        <div class="editor-field">
            @Html.DropDownList("ParentID", String.Empty)
            @Html.ValidationMessageFor(model => model.ParentID)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.ColorStyleID, "ColorStyle")
        </div>
        <div class="editor-field">
            @Html.DropDownList("ColorStyleID")
            @Html.ValidationMessageFor(model => model.ColorStyleID)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Enable)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Enable)
            @Html.ValidationMessageFor(model => model.Enable)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.MenuID, "Menu")
        </div>
        <div class="editor-field">
            @Html.DropDownList("MenuID")
            @Html.ValidationMessageFor(model => model.MenuID)
        </div>

        <div class="editor-label" style="margin-top: 20px;">
            <input type="submit" value="Create" />
        </div>
    </fieldset>
}

  <script>
      $(document).ready(function () {
          $("#slItemID").change(function () {
              var value = $(this).val();
              if (value != "")
              {
                  $("#Menu_URL").val(value);
                  $("#Menu_URL").attr("readonly", "readonly");
              }
              else
              {
                  $("#Menu_URL").val("");
                  $("#Menu_URL").removeAttr("readonly");
              }
          });
      });
  </script>
@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}
